#include <stdio.h>

#define MAX_SIZE 100

typedef struct
{
  int data[MAX_SIZE];
  int top;
} Stack;

void initStack(Stack *s)
{
  s->top = -1;
}

int isFull(Stack *s)
{
  return s->top == MAX_SIZE - 1;
}
int isEmpty(Stack *s)
{
  return s->top == -1;
}
int main()
{
  Stack s;
  initStack(&s);
  int decimal, remainder;
  printf("Enter a decimal number: ");
  scanf("%d", &decimal);
  while (decimal != 0)
  {
    remainder = decimal % 8;
    if (isFull(&s))
    {
      printf("Stack overflow\n");
      return 1;
    }
    s.data[++s.top] = remainder;
    decimal /= 8;
  }
  printf("Octal representation: ");
  while (!isEmpty(&s))
  {
    printf("%d", s.data[s.top--]);
  }
  printf("\n");
  return 0;
}